package com.fastgwt.client.mvc.view;

import com.fastgwt.shared.dto.Employee;
import com.fastgwt.shared.mvctemplate.view.GwtView;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.form.FieldLabel;

public class EmployeeView extends GwtView<Employee> {

	protected EmployeeEditor employeeEditor = new EmployeeEditor();

	public TextButton btnSave = new TextButton("Save");

	private TextButton btnCancel = new TextButton("Cancel");

	public EmployeeView() {

		//
		// FieldSet fieldSet = new FieldSet();
		// fieldSet.setHeadingText("User Information");
		// fieldSet.setCollapsible(true);
		// this.add(fieldSet);
		//
		// VerticalLayoutContainer p = new VerticalLayoutContainer();
		// fieldSet.add(p);

		initialize();

	}

	@Override
	protected void initialize() {
		// TODO Auto-generated method stub
		this.setHeadingText("Create Emplyee");
		this.setWidth(350);

		VerticalLayoutContainer p = new VerticalLayoutContainer();
		this.add(p);
		employeeEditor.getEmployeeId().setAllowBlank(false);

		p.add(new FieldLabel(employeeEditor.employeeId, "Employee Id"),
				new VerticalLayoutData(1, -1));

		employeeEditor.getEmployeeName().setAllowBlank(false);
		p.add(new FieldLabel(employeeEditor.employeeName, "First Name"),
				new VerticalLayoutData(1, -1));

		employeeEditor.getEmployeeSurname().setAllowBlank(false);
		p.add(new FieldLabel(employeeEditor.employeeSurname, "Last Name"),
				new VerticalLayoutData(1, -1));

		employeeEditor.getJob().setAllowBlank(false);
		p.add(new FieldLabel(employeeEditor.getJob(), "Job desc."),
				new VerticalLayoutData(1, -1));

		p.add(new FieldLabel(employeeEditor.email, "Email"),
				new VerticalLayoutData(1, -1));
		this.addButton(btnSave);
		this.addButton(btnCancel);

	}

	//
	// public TextButton getBtnSave() {
	// return btnSave;
	// }

	public EmployeeEditor getEmployeeEditor() {
		return employeeEditor;
	}

	public void setEmployeeEditor(EmployeeEditor employeeEditor) {
		this.employeeEditor = employeeEditor;
	}

}
